#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
    int n = 0;
    int count = 1;
    scanf("%d", &n);
    for (int i = 1; i <= n;i++)
    {
        int flag = 1;
        int num1 = i;
        int num2 = i * i;
        while (num1)
        {
            if (num1 % 10 != num2 % 10)
            {
                flag = 0;
            }
            num1 /= 10;
            num2 /= 10;
        }
        if (flag)
        {
            count++;
        }
    }
    printf("%d", count);
    return 0;
}